package com.scs.application.modules.upms.security.authenticator;

import com.scs.application.modules.upms.security.integration.authenticator.IntegrationAuthentication;
import com.scs.application.modules.upms.security.integration.authenticator.IntegrationAuthenticator;
import com.scs.application.modules.upms.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 */
public class IntegrationUserDetailsService {
    private List<IntegrationAuthenticator> authenticators;

    @Autowired(required = false)
    public void setIntegrationAuthenticators(List<IntegrationAuthenticator> authenticators) {
        this.authenticators = authenticators;
    }

    private UserVO authenticate(IntegrationAuthentication integrationAuthentication) {
        if (this.authenticators != null) {
            for (IntegrationAuthenticator authenticator : authenticators) {
                if (authenticator.support(integrationAuthentication)) {
                    return authenticator.authenticate(integrationAuthentication);
                }
            }
        }
        return null;
    }
}

